#AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 -d
#AutoIt3Wrapper_Run_After=md "%scriptdir%\Versions\%fileversion%"
#AutoIt3Wrapper_Run_After=copy "%in%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3"
#AutoIt3Wrapper_Run_After=copy "%out%" "%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe"
#AutoIt3Wrapper_UseX64=n

;**** Function Name List ****
; _exit
; term
; Test_DetailedInfo
; Test_FileNameShouldBeImage3jpg
; Test_HeightShouldBe533
; Test_IMShouldShutDown
; Test_IMShouldStartUp
; Test_List
; Test_Manual
; Test_NameShouldBeImage3
; Test_ShouldBeAdaptiveBlur
; Test_ShouldBeAdaptiveResize
; Test_ShouldBeAdaptiveSharpen
; Test_ShouldBeAligned
; Test_ShouldBeAnnotated
; Test_ShouldBeAutoGamma
; Test_ShouldBeAutoLevel
; Test_ShouldBeAutoOrient
; Test_ShouldBeBlackThreshold
; Test_ShouldBeBlueShift
; Test_ShouldBeBlur
; Test_ShouldBeBrighter
; Test_ShouldBeCharcoal
; Test_ShouldBeCMYKColorize
; Test_ShouldBeColorVerified
; Test_ShouldBeContrasted
; Test_ShouldBeCropped
; Test_ShouldBeCSS_Array
; Test_ShouldBeCSS_CSS
; Test_ShouldBeCSS_Wild
; Test_ShouldBeDeciphered
; Test_ShouldBeEdgeDetected
; Test_ShouldBeEnciphered
; Test_ShouldBeGravitated
; Test_ShouldBeImplode
; Test_ShouldBeJPG
; Test_ShouldBeModulated
; Test_ShouldBeMonochrome
; Test_ShouldBeNegated
; Test_ShouldBeNormalized
; Test_ShouldBePainted
; Test_ShouldBeRedBG_ColorName
; Test_ShouldBeRedBG_Hex
; Test_ShouldBeRotated300Deg
; Test_ShouldBeRotated90Deg
; Test_ShouldBeRotatedNeg180Deg
; Test_ShouldBeRotatedNeg90Deg
; Test_ShouldBeSpread
; Test_ShouldBeSteelBlueBG_ColorName
; Test_ShouldBeSteelBlueBG_Hex
; Test_ShouldNotBeBlueShift
; Test_WidthShouldBe60
; Test_WidthShouldBe652
; Tests



#include-once

#include "AutoItObject.au3"
#include "TDD Framework.au3"
#include "ImageMagickObject Object.au3"
#include <Misc.au3>

_Singleton(@ScriptName)

HotKeySet("{ESC}", "_Exit")

OnAutoItExitRegister("term")

DirRemove(@ScriptDir & "\Pictures\", 1)
DirCreate(@ScriptDir & "\Pictures\")

_AutoItObject_Startup()

Global $Assert = Tests(5)

;$Assert.IMShouldStartUp()

;$Assert.ListTypes("Geometry")

$Assert.ShouldBeJPG()
$Assert.NameShouldBeImage3()
$Assert.FileNameShouldBeImage3jpg()
$Assert.HeightShouldBe533()
$Assert.WidthShouldBe652()
$Assert.WidthShouldBe60()
$Assert.DetailedInfo()

$Assert.ShouldBeAdaptiveBlur()
$Assert.ShouldBeAdaptiveResize()
$Assert.ShouldBeAdaptiveSharpen()
$Assert.ShouldBeAlpha()
$Assert.ShouldBeAnnotated()
$Assert.ShouldBeAutoGamma()
$Assert.ShouldBeAutoLevel()
$Assert.ShouldBeAutoOrient()
$Assert.ShouldBeAligned()
$Assert.ShouldBeBrighter()
$Assert.ShouldBeBlackThreshold()
$Assert.ShouldBeBlueShift()
$Assert.ShouldNotBeBlueShift()
$Assert.ShouldBeBlur()
$Assert.ShouldBeCharcoal()
$Assert.ShouldBeCMYKColorize()
$Assert.ShouldBeComment()
$Assert.ShouldBeContrasted()
$Assert.ShouldBeCropped()
$Assert.ShouldBeDespeckled()
$Assert.ShouldBeEdgeDetected()
$Assert.ShouldBeEmbossed()
$Assert.ShouldBeEnciphered()
$Assert.ShouldBeDeciphered()
$Assert.ShouldBeFilesize()
$Assert.ShouldBeFlipped()
$Assert.ShouldBeFlopped()
$Assert.ShouldBeGamma()
;$Assert.ShouldBeGravitated()
$Assert.ShouldBeImplode()
$Assert.ShouldBeModulated()
$Assert.ShouldBeMonochrome()
$Assert.ShouldBeNegated()
$Assert.ShouldBeNormalized()
$Assert.ShouldBePainted()
$Assert.ShouldBePolaroid()
$Assert.ShouldBePageGeometry()
$Assert.ShouldBeRedBG_ColorName()
$Assert.ShouldBeRedBG_Hex()
$Assert.ShouldBeRotated90Deg()
$Assert.ShouldBeRotatedNeg90Deg()
$Assert.ShouldBeRotated300Deg()
$Assert.ShouldBeRotatedNeg180Deg()
$Assert.ShouldBeSepiaTone()
$Assert.ShouldBeSpread()
$Assert.ShouldBeSteelBlueBG_ColorName()
$Assert.ShouldBeSteelBlueBG_Hex()

;$Assert.ShouldBeColorVerified()
;$Assert.ShouldBeCSS_CSS()
;$Assert.ShouldBeCSS_Wild()
;$Assert.ShouldBeCSS_Array()

;$Assert.IMShouldShutDown() ; no need to explicitly call this -- just for testing

; =================================================================================================

Func Tests($image = 3)
	$image -= 1

	Local Const $SaveDir	     = @ScriptDir & "\Pictures\"
	Local Const $TestDir 	     = @ScriptDir & "\Test Images\"
	Local Const $image1 	     = $TestDir & "Image1.jpg"
	Local Const $image2 	     = $TestDir & "Image2.jpg"
	Local Const $image3          = $TestDir & "Image3.jpg"
	Local Const $image4          = $TestDir & "Image4.jpg"
	Local Const $image5          = $TestDir & "Image5.jpg"
	Local Const $image6          = $TestDir & "Image6.jpg"
	Local Const $image7          = $TestDir & "Image7.jpg"
	Local Const $imagePNG        = $TestDir & "drawn.png"
	Local Const $sizes[2][7]     = [[952, 666, 652, 457, 1311, 498, 474], [1264, 919, 533, 727, 1600, 640, 693]]
	Local Const $geo[7]          = ["952x1264+0+0", "666x919+0+0", "652x533+0+0", "457x727+0+0", "1311x1600+0+0", "498x640+0+0", "474x693+0+0"]
	Local Const $names[7]        = ["Image1", "Image2", "Image3", "Image4", "Image5", "Image6", "Image7"]
	Local Const $filesizes[7]    = ["455011B", "151942B", "113525B", "206802B", "1573735B", "B", "B"]
	Local Const $image_list[7]   = [$image1, $image2, $image3, $image4, $image5, $image6, $image7]
	Local Const $image_list_CSS  = $image1 & ',' & $image2 & ',' & $image3 & ',' & $image4 & ',' & $image5 & ',' & $image6 & ',' & $image7
	Local Const $image_list_wild = $TestDir & "*.jpg"
	Local Const $IMDLL           = @SystemDir & "\ImageMagickObject.dll"

	Local $this = _AutoItObject_Class()

	$this.AddProperty("TDD"		     , $ELSCOPE_PRIVATE, TDD())
	$this.AddProperty("Image"		 , $ELSCOPE_PRIVATE, $image_list[$image])
	$this.AddProperty("ImagePNG"	 , $ELSCOPE_PRIVATE, $imagePNG)
	$this.AddProperty("ImageList"	 , $ELSCOPE_PRIVATE, $image_list)
	$this.AddProperty("ImageListCSS" , $ELSCOPE_PRIVATE, $image_list_CSS)
	$this.AddProperty("ImageListWild", $ELSCOPE_PRIVATE, $image_list_wild)
	$this.AddProperty("Test_Width"   , $ELSCOPE_PRIVATE, $sizes[0][$image])
	$this.AddProperty("Test_Height"  , $ELSCOPE_PRIVATE, $sizes[1][$image])
	$this.AddProperty("Test_Name"	 , $ELSCOPE_PRIVATE, $names[$image])
	$this.AddProperty("Size"		 , $ELSCOPE_PRIVATE, $filesizes[$image])
	$this.AddProperty("CommentProp"  , $ELSCOPE_PRIVATE, "ImageMagickObject Object")
	$this.AddProperty("Geo"		     , $ELSCOPE_PRIVATE, $geo[$image])
	$this.AddProperty("Ext"          , $ELSCOPE_PRIVATE, "jpg")
	$this.AddProperty("SaveDir"	     , $ELSCOPE_PRIVATE, $SaveDir)
	$this.AddProperty("IMDLL"		 , $ELSCOPE_PRIVATE, $IMDLL)
	$this.AddProperty(""             , $ELSCOPE_PRIVATE, "")


	$this.AddMethod("DetailedInfo"				   , "Test_DetailedInfo")
	$this.AddMethod("FileNameShouldBeImage3jpg"	   , "Test_FileNameShouldBeImage3jpg")
	$this.AddMethod("HeightShouldBe533"			   , "Test_HeightShouldBe533")
	$this.AddMethod("IMShouldShutDown"			   , "Test_IMShouldShutDown")
	$this.AddMethod("IMShouldStartUp"			   , "Test_IMShouldStartUp")
	$this.AddMethod("ListTypes"                    , "Test_List")
	$this.AddMethod("NameShouldBeImage3"           , "Test_NameShouldBeImage3")
	$this.AddMethod("ShouldBeAdaptiveBlur"         , "Test_ShouldBeAdaptiveBlur")
	$this.AddMethod("ShouldBeAdaptiveResize"       , "Test_ShouldBeAdaptiveResize")
	$this.AddMethod("ShouldBeAdaptiveSharpen"      , "Test_ShouldBeAdaptiveSharpen")
	$this.AddMethod("ShouldBeAlpha"                , "Test_ShouldBeAlpha")
	$this.AddMethod("ShouldBeAligned"              , "Test_ShouldBeAligned")
	$this.AddMethod("ShouldBeAnnotated"            , "Test_ShouldBeAnnotated")
	$this.AddMethod("ShouldBeAutoGamma"            , "Test_ShouldBeAutoGamma")
	$this.AddMethod("ShouldBeAutoLevel"            , "Test_ShouldBeAutoLevel")
	$this.AddMethod("ShouldBeAutoOrient"           , "Test_ShouldBeAutoOrient")
	$this.AddMethod("ShouldBeBrighter"             , "Test_ShouldBeBrighter")
	$this.AddMethod("ShouldBeBlackThreshold"       , "Test_ShouldBeBlackThreshold")
	$this.AddMethod("ShouldBeBlueShift"            , "Test_ShouldBeBlueShift")
	$this.AddMethod("ShouldBeBlur"                 , "Test_ShouldBeBlur")
	$this.AddMethod("ShouldBeColorVerified"        , "Test_ShouldBeColorVerified")
	$this.AddMethod("ShouldBeComment"              , "Test_ShouldBeComment")
	$this.AddMethod("ShouldBeContrasted"           , "Test_ShouldBeContrasted")
	$this.AddMethod("ShouldBeCharcoal"             , "Test_ShouldBeCharcoal")
	$this.AddMethod("ShouldBeCMYKColorize"         , "Test_ShouldBeCMYKColorize")
	$this.AddMethod("ShouldBeCropped"              , "Test_ShouldBeCropped")
	$this.AddMethod("ShouldBeCSS_CSS"              , "Test_ShouldBeCSS_CSS")
	$this.AddMethod("ShouldBeCSS_Wild"             , "Test_ShouldBeCSS_Wild")
	$this.AddMethod("ShouldBeCSS_Array"            , "Test_ShouldBeCSS_Array")
	$this.AddMethod("ShouldBeDeciphered"           , "Test_ShouldBeDeciphered")
	$this.AddMethod("ShouldBeDespeckled"           , "Test_ShouldBeDespeckled")
	$this.AddMethod("ShouldBeEdgeDetected"         , "Test_ShouldBeEdgeDetected")
	$this.AddMethod("ShouldBeEmbossed"             , "Test_ShouldBeEmbossed")
	$this.AddMethod("ShouldBeEnciphered"           , "Test_ShouldBeEnciphered")
	$this.AddMethod("ShouldBeFilesize"             , "Test_ShouldBeFilesize")
	$this.AddMethod("ShouldBeFlipped"              , "Test_ShouldBeFlipped")
	$this.AddMethod("ShouldBeFlopped"              , "Test_ShouldBeFlopped")
	$this.AddMethod("ShouldBeGamma"                , "Test_ShouldBeGamma")
	$this.AddMethod("ShouldBeGravitated"           , "Test_ShouldBeGravitated")
	$this.AddMethod("ShouldBeImplode"              , "Test_ShouldBeImplode")
	$this.AddMethod("ShouldBeJPG"                  , "Test_ShouldBeJPG")
	$this.AddMethod("ShouldBeModulated"            , "Test_ShouldBeModulated")
	$this.AddMethod("ShouldBeMonochrome"           , "Test_ShouldBeMonochrome")
	$this.AddMethod("ShouldBeNegated"              , "Test_ShouldBeNegated")
	$this.AddMethod("ShouldBeNormalized"           , "Test_ShouldBeNormalized")
	$this.AddMethod("ShouldBePainted"              , "Test_ShouldBePainted")
	$this.AddMethod("ShouldBePageGeometry"         , "Test_ShouldBePageGeometry")
	$this.AddMethod("ShouldBePolaroid"             , "Test_ShouldBePolaroid")
	$this.AddMethod("ShouldBeRedBG_ColorName"      , "Test_ShouldBeRedBG_ColorName")
	$this.AddMethod("ShouldBeRedBG_Hex"            , "Test_ShouldBeRedBG_Hex")
	$this.AddMethod("ShouldBeRotated90Deg"         , "Test_ShouldBeRotated90Deg")
	$this.AddMethod("ShouldBeRotatedNeg90Deg"      , "Test_ShouldBeRotatedNeg90Deg")
	$this.AddMethod("ShouldBeRotated300Deg"        , "Test_ShouldBeRotated300Deg")
	$this.AddMethod("ShouldBeRotatedNeg180Deg"     , "Test_ShouldBeRotatedNeg180Deg")
	$this.AddMethod("ShouldBeSepiaTone"            , "Test_ShouldBeSepiaTone")
	$this.AddMethod("ShouldBeSpread"               , "Test_ShouldBeSpread")
	$this.AddMethod("ShouldBeSteelBlueBG_ColorName", "Test_ShouldBeSteelBlueBG_ColorName")
	$this.AddMethod("ShouldBeSteelBlueBG_Hex"      , "Test_ShouldBeSteelBlueBG_Hex")
	$this.AddMethod("ShouldNotBeBlueShift"         , "Test_ShouldNotBeBlueShift")
	$this.AddMethod("WidthShouldBe652"             , "Test_WidthShouldBe652")
	$this.AddMethod("WidthShouldBe60"              , "Test_WidthShouldBe60")
	$this.AddMethod("", "Test_")

	Return $this.Object
EndFunc

; =================================================================================================

Func Test_DetailedInfo(ByRef $this)
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	ConsoleWrite($IM.ImageInfo($this.Image) & @LF)
EndFunc

; =================================================================================================

Func Test_FileNameShouldBeImage3jpg(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $IM.FileName($this.Image)
	Return $this.TDD.Equal($this.Test_Name & '.' & $this.Ext, $Result, $test_name)
EndFunc

; =================================================================================================

Func Test_HeightShouldBe533(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = Number($IM.Height($this.Image))
	Return $this.TDD.Equal($this.Test_Height, $Result, $test_name)
EndFunc

; =================================================================================================

Func Test_IMShouldShutDown(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $IM.ShutDown()
	Return $this.TDD.NotObject($Result, $test_name)
EndFunc

; =================================================================================================

Func Test_IMShouldStartUp(ByRef $this, Const $ErrorCheck = True)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $IM.StartUp($ErrorCheck)
	$this.TDD.Object($Result, $test_name)
EndFunc

; =================================================================================================

Func Test_List(ByRef $this, Const $Type)
	#forceref $this
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.List($Type)
EndFunc

; =================================================================================================

Func Test_NameShouldBeImage3(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $IM.Name($this.Image)
	$this.TDD.Equal($this.Test_Name, $Result, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAdaptiveSharpen(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Adaptive Sharpen.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.AdaptiveSharpen($this.Image, $Picname, 10, 50)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAdaptiveResize(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Adaptive Resize.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.AdaptiveResize($this.Image, $Picname, "150%")
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAdaptiveBlur(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Adaptive Blur"

	Local $IM = ImageMagickObject()
	$IM.StartUp(True)

	Local $tmpName

	For $i = 1 To 5
		$tmpName = $Picname & $i & ".jpg"
		$IM.AdaptiveBlur($this.Image, $tmpName, $i, 10)
		$this.TDD.FileExists($tmpName, $test_name)
	Next
EndFunc

; =================================================================================================

Func Test_ShouldBeAlpha(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $alpha = $IM.Alpha($this.Image)
	$this.TDD.Equal("On", $alpha, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAligned(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Aligned "
	Local Const $Alignment[9] = ["Horizontal", "Vertical", "horizontal", "vertical", "+append", "-append", "h", "v", '']
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	For $i = 0 To 8
		$IM.Append($this.ImageList, $Picname & $Alignment[$i] & ".jpg", $Alignment[$i], '', '')
		$this.TDD.FileExists($Picname & $Alignment[$i] & ".jpg", $test_name)
	Next
EndFunc

; =================================================================================================

;~ Func Test_AhouldBeAligned(ByRef $this)
;~ 	Local Const $test_name = $this.__name__

;~ 	Local Const $Picname = $this.SaveDir & "Aligned1_ "

;~ 	Local Const $Alignment = $this.AlignmentList
;~ 	Local Const $UpBound = UBound($Alignment) - 1

;~ 	For $i = 0 To $UpBound
;~ 		$this.Append($this.ImageList, $Picname & $Alignment[$i] & ".jpg", $Alignment[$i], '', '')
;~ 		$this.TDD.FileExists($Picname & $Alignment[$i] & ".jpg", $test_name)
;~ 	Next
;~ EndFunc

; =================================================================================================

Func Test_ShouldBeAnnotated(ByRef $this)
	Local Const $test_name = $this.__name__

	Local $Picname = $this.SaveDir & "Annotated.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Annotate($this.Image, $Picname, 100, "AutoIt ROOLZ!")
	$this.TDD.FileExists($Picname, $test_name)

;~ 	$picname = $this.SaveDir & "Annotated1.jpg"
;~ 	$IM.Annotate($this.Image, $picname, "10", "AutoIt ROOLZ!")
;~ 	$this.TDD.FileExists($picname, $test_name)

;~ 	$picname = $this.SaveDir & "Annotated2.jpg"
;~ 	$IM.Annotate($this.Image, $picname, '', '')
;~ 	$this.TDD.FileDoesNotExist($picname, $test_name)

;~ 	$picname = $this.SaveDir & "Annotated3.jpg"
;~ 	$IM.Annotate($this.Image, $picname, '', "AutoIt ROOLZ!")
;~ 	$this.TDD.FileDoesNotExist($picname, $test_name)

;~ 	$picname = $this.SaveDir & "Annotated4.jpg"
;~ 	$IM.Annotate($this.Image, $picname, 30, '')
;~ 	$this.TDD.FileDoesNotExist($picname, $test_name)

	$Picname = $this.SaveDir & "Annotated5.jpg"
	$IM.Annotate($this.Image, $Picname, -30, "AutoIt ROOLZ!")
	$this.TDD.NotFileExists($Picname, $test_name)

;~ 	$picname = $this.SaveDir & "Annotated6.jpg"
;~ 	$IM.Annotate($this.Image, $picname, 30, 123456789)
;~ 	$this.TDD.FileExists($picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAutoOrient(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "AutoOrient.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.AutoOrient($this.Image, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAutoLevel(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "AutoLevel.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.AutoLevel($this.Image, $Picname)
	Return $this.Tdd.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeAutoGamma(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "AutoGamma.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.AutoGamma($this.Image, $Picname)
	Return $this.Tdd.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeBlackThreshold(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Black Threshold.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.BlackThreshold($this.Image, $Picname, "50%")
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeBlur(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Blur.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Blur($this.Image, $Picname, 10)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeBlueShift(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "BlueShift.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.BlueShift($this.Image, $Picname, 1.5)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeBrighter(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $Picname = $this.SaveDir & "Brighter.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Brightness($this.Image, $Picname, 50)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeCharcoal(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Charcoal.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Charcoal($this.Image, $Picname, 5)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeCMYKColorize(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "White_Converted.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.CMYKColorize($this.Image, $Picname, 0, 57, 57, 39)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeColorVerified(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $this.ColorVerifier("SteelBlue")
	If @error <> 0 Then MsgBox(0, '', @error)
	Return $this.TDD.Equal($Result, "steelblue", $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeComment(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $comment = $IM.Comment($this.Image)
	Return $this.TDD.Equal($this.CommentProp, $comment, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeContrasted(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Contrast.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Contrast($this.Image, $Picname, 50)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeCropped(ByRef $this)
	Local Const $test_name = $this.__name__
	DirCreate(@ScriptDir & "\Pictures\Cropped")
	Local Const $Picname = $this.SaveDir & "Cropped\Cropped.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Crop($this.Image, $Picname, 60)
	Return $this.TDD.FileExists($this.SaveDir & "Cropped\Cropped-1.jpg", $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeDeciphered(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Decipher.png"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Decipher($this.SaveDir & "Encipher.png", $Picname, @ScriptDir & "\PassPhrase.txt")
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeDespeckled(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $picname = $this.SaveDir & "Despeckle.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Despeckle($this.Image, $picname)
	Return $this.TDD.FileExists($picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeEdgeDetected(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $picname = $this.SaveDir & "Edge0.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Edge($this.Image, 0, $picname)
	Return $this.TDD.FileExists($picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeEmbossed(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $picname = $this.SaveDir & "Emboss.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Emboss($this.Image, 0, $picname)
	Return $this.TDD.FileExists($picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeEnciphered(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Encipher.png"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Encipher($this.ImagePNG, $Picname, @ScriptDir & "\PassPhrase.txt")
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeFilesize(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $size = $IM.Filesize($this.Image)
	Return $this.TDD.Equal($this.Size, $size, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeFlipped(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Flipped.png"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Flip($this.Image, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeFlopped(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Flopped.png"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Flop($this.Image, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeGamma(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Gamma.png"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Gamma($this.Image, 2.3, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeGravitated(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Gravitated "
	Local Const $Gravity = $this.GravityList
	Local Const $UpBound = UBound($Gravity) - 1
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)

	For $i = 0 To $UpBound
		$IM.Append($this.ImageList, $Picname & $Gravity[$i] & ".jpg", '', $Gravity[$i], '')
;~ 		ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Gravity[$i] = ' & $Gravity[$i] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
		$this.TDD.FileExists($Picname & $Gravity[$i] & ".jpg", $test_name)
	Next
EndFunc

; =================================================================================================

Func Test_ShouldBeImplode(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Implode.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Implode($this.Image, $Picname, 5)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeJPG(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $IM.Extension($this.Image)
	Return $this.TDD.Equal($this.Ext, $Result, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeModulated(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Modulated.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Modulate($this.Image, $Picname, 120, 90, 50)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeMonochrome(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Monochrome.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Monochrome($this.Image, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeNegated(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Negate.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Negate($this.Image, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeNormalized(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Normalize.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Normalize($this.Image, $Picname)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBePainted(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Painted.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Paint($this.Image, $Picname, 2)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBePageGeometry(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $geo = $IM.PageGeometry($this.Image)
	Return $this.TDD.Equal($this.Geo, $geo, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBePolaroid(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname1 = $this.SaveDir & "Polaroid-Random.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Polaroid($this.Image, $Picname1)
	$this.TDD.FileExists($Picname1, $test_name)

	Local Const $Picname2 = $this.SaveDir & "Polaroid+15.jpg"
	$IM.Polaroid($this.Image, $Picname2, 15)
	Return $this.TDD.FileExists($Picname2, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeRedBG_Hex(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "RedBG Hex.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Append($this.ImageList, $Picname, '', '', 0xFF0000)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeRedBG_ColorName(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "RedBG ColorName.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Append($this.ImageList, $Picname, '', '', "red")
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeRotatedNeg180Deg(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Negative180.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $beforeHeight = $IM.Height($this.Image)
	$IM.Rotate($this.Image, $Picname, -180)
	Local Const $afterHeight = $IM.Height($Picname)
	Return $this.TDD.Equal($beforeHeight, $afterHeight, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeRotated300Deg(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Positive300.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $beforeHeight = $IM.Height($this.Image)
	$IM.Rotate($this.Image, $Picname, 300)
	Local Const $afterHeight = $IM.Height($Picname)
	Return $this.TDD.NotEqual($beforeHeight, $afterHeight, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeRotatedNeg90Deg(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Negative90.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $beforeWidth = $IM.Width($this.Image)
	$IM.Rotate($this.Image, $Picname, -90)
	Local Const $afterWidth = $IM.Width($Picname)
	Return $this.TDD.NotEqual($beforeWidth, $afterWidth, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeRotated90Deg(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Positive90.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $beforeWidth = $IM.Width($this.Image)
	$IM.Rotate($this.Image, $Picname, 90)
	Local Const $afterWidth = $IM.Width($Picname)
	Return $this.TDD.NotEqual($beforeWidth, $afterWidth, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeSepiaTone(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Sepiatone.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Sepiatone($this.Image, $Picname, 80)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeSpread(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "Spread.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Spread($this.Image, $Picname, 2)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeSteelBlueBG_Hex(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "SteelBlue Hex BG.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Append($this.ImageList, $Picname, '', '', 0x4682B4)
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldBeSteelBlueBG_ColorName(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "SteelBlue ColorName BG.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Append($this.ImageList, $Picname, '', '', "SteelBlue")
	Return $this.TDD.FileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_ShouldNotBeBlueShift(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "NotBlueShift.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.BlueShift($this.Image, $Picname, "ABC")
	Return $this.TDD.NotFileExists($Picname, $test_name)
EndFunc

; =================================================================================================

Func Test_WidthShouldBe60(ByRef $this)
	Local Const $test_name = $this.__name__
	Local Const $Picname = $this.SaveDir & "ResizeWidth60.jpg"
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	$IM.Resize($this.Image, $Picname, 60)
	Local Const $Result = $IM.Width($Picname)
	Return $this.TDD.Equal(60, Number($Result), $test_name)
EndFunc

; =================================================================================================

Func Test_WidthShouldBe652(ByRef $this)
	Local Const $test_name = $this.__name__
	Local $IM = ImageMagickObject()
	$IM.StartUp(True)
	Local Const $Result = $IM.Width($this.Image)
	Return $this.TDD.Equal($this.Test_Width, Number($Result), $test_name)
EndFunc

; =================================================================================================

#Region ;**** IM_ConvertToCSS ****
;~ Func Test_ShouldBeCSS_Array(ByRef $this)
;~ 	Local Const $test_name = $this.__name__
;~ 	Local $IM = ImageMagickObject()
;~ 	$IM.StartUp(True)
;~ 	Local Const $Result = $IM.ConvertToCSS($this.ImageList)
;~ 	Return $this.TDD.Equal($this.ImageListCSS, $Result, $test_name)
;~ EndFunc

;~ ; =================================================================================================

;~ Func Test_ShouldBeCSS_CSS(ByRef $this)
;~ 	Local Const $test_name = $this.__name__
;~ 	Local $IM = ImageMagickObject()
;~ 	$IM.StartUp(True)
;~ 	Local Const $Result = $IM.ConvertToCSS($this.ImageListCSS)
;~ 	Return $this.TDD.Equal($this.ImageListCSS, $Result, $test_name)
;~ EndFunc

;~ ; =================================================================================================

;~ Func Test_ShouldBeCSS_Wild(ByRef $this)
;~ 	Local Const $test_name = $this.__name__
;~ 	Local $IM = ImageMagickObject()
;~ 	$IM.StartUp(True)
;~ 	Local Const $Result = $IM.ConvertToCSS($this.ImageListWild)
;~ 	Return $this.TDD.Equal($this.ImageListWild, $Result, $test_name)
;~ EndFunc
#EndRegion ;**** IM_ConvertToCSS ****

Func _exit()
	Exit
EndFunc   ;==>_exit

Func term()
	ShellExecute($Assert.SaveDir)
	$Assert = ''
EndFunc   ;==>term
